package com.qf.feign;

import com.qf.pojo.UserAddress;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author wbzs,
 * @date 2022/10/20,
 * @time 22:28,
 * 当前feign的主要功能是通过接口的方式声明式的访问远程服务器
 */
//声明当前feign中的接口都是请求addressprovidereureka04的服务的
    @Component
@FeignClient(name = "addressprovidereureka041",fallback = AddressFeignImp.class)
public interface AddressFeign {

    /*
    id：要请求的目标接口的参数
    return:我们期望接口的返回数据解析成什么格式的数据
    规则:mapping 里面是我们要请求的目标地址，方法的参数会作为请求参数传递过去，其实就是和我们的springmvc反过来
     */

    @RequestMapping("/address/info/{id}")
    public UserAddress findAddressByid(@PathVariable Integer id);



    @RequestMapping("/address/infos")
    public UserAddress findByid(@RequestParam(name = "id") Integer id, @RequestParam(name = "address") String address) ;

}
